﻿using System;
using System.Collections.Generic;

namespace smp.ButterflyCakes.Models.ViewModels.Attachments
{
    public class ViewFilesView
    {
        public ViewFilesView()
        {
            
        }

        public ViewFilesView(Guid orderId, IEnumerable<ViewFilesDataItem> fileItems, List<DiagramItem> diagrams , bool canManage)
        {
            OrderId = orderId;
            Images = new List<FileItem>();
            Files = new List<FileItem>();
            Diagrams = diagrams;
            CanManage = canManage;
            foreach(var item in fileItems)
            {
                if(item.IsImage)
                {
                    Images.Add(new FileItem(item));
                }
                Files.Add(new FileItem(item));
            }
        }
        
        public Guid OrderId { get; set; }
        public List<DiagramItem> Diagrams { get; set; }
        public List<FileItem> Images { get; set; }
        public List<FileItem> Files { get; set; }
        public bool CanManage { get; set; }
    }

    public class FileItem
    {
        public FileItem(ViewFilesDataItem data)
        {
            Id = data.FileId;
            Description = data.Desription;
            Name = data.Name;
        }
        public Guid Id { get; set; }
        public string Description { get; set; }
        public string Name { get; set; }
    }

    public class ViewFilesDataItem
    {
        public Guid OrderId { get; set; }
        public Guid FileId { get; set; }
        public bool IsImage { get; set; }
        public Guid? ComponentId { get; set; }
        public string Desription { get; set; }
        public string Name { get; set; }
    }
}
